var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
  __markAsModule(target);
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
  if (module2 && typeof module2 === "object" || typeof module2 === "function") {
    for (let key of __getOwnPropNames(module2))
      if (!__hasOwnProp.call(target, key) && key !== "default")
        __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
  }
  return target;
};
var __toModule = (module2) => {
  return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
__export(exports, {
  default: () => create_default
});
var import_chalk = __toModule(require("chalk"));
var import_fs_extra = __toModule(require("fs-extra"));
var import_inquirer = __toModule(require("inquirer"));
var import_ora = __toModule(require("ora"));
var import_path = __toModule(require("path"));
var import_dyi_tool = __toModule(require("dyi-tool"));
const Create = (name, options) => __async(void 0, null, function* () {
  const cwd = process.cwd();
  const targetPath = import_path.default.join(cwd, name);
  const { projectName } = yield (0, import_inquirer.prompt)({
    name: "projectName",
    type: "list",
    choices: [
      { name: "react-tmp", value: "react-tmp" },
      { name: "vue-tmp", value: "vue-tmp" },
      { name: "taro-tmp", value: "taro-tmp" }
    ],
    message: "\u8BF7\u9009\u62E9\u4E00\u4E2A\u9879\u76EE\u6A21\u7248\u8FDB\u884C\u521B\u5EFA"
  });
  if ((0, import_fs_extra.existsSync)(targetPath)) {
    if (options.force) {
      yield (0, import_fs_extra.remove)(targetPath);
    } else {
      const { replace } = yield (0, import_inquirer.prompt)([
        {
          name: "replace",
          type: "list",
          message: `\u9879\u76EE\u5DF2\u5B58\u5728\u3001\u662F\u5426\u786E\u8BA4\u8986\u76D6? ${import_chalk.default.grey("\u8986\u76D6\u540E\u539F\u9879\u76EE\u65E0\u6CD5\u6062\u590D")}`,
          choices: [
            { name: "\u786E\u8BA4\u8986\u76D6", value: true },
            { name: "\u518D\u8003\u8651\u4E0B\uFF0C\u6682\u4E0D\u8986\u76D6", value: false }
          ]
        }
      ]);
      if (!replace) {
        return;
      }
      yield (0, import_fs_extra.remove)(targetPath);
    }
  }
  console.log(`
`);
  const spinner = (0, import_ora.default)("downloading template...");
  spinner.start();
  const root = import_path.default.resolve("./src/template/", projectName);
  if (!import_dyi_tool.copyDir) {
    console.log(import_chalk.default.red(`copyDir \u4E0D\u5B58\u5728 ...`));
  }
  const res = yield (0, import_dyi_tool.copyDir)(root, `./${name}`);
  if (res === false) {
    console.log(import_chalk.default.red(`copyDir(${root}, ${name}) failed ...`));
    spinner.fail("downloading failed ...");
    return false;
  }
  spinner.succeed();
  console.log(`${import_chalk.default.green("\n Successfully created project")}  ${import_chalk.default.cyan(name)}`);
  console.log(`
 cd ${import_chalk.default.cyan(name)}`);
  console.log("\n npm install");
  console.log("\n npm run dev \n");
});
var create_default = Create;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});
